package com.ui.recyclerview.PagerLayoutManager;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;

import com.gcssloop.widget.PagerGridLayoutManager;
import com.gcssloop.widget.PagerGridSnapHelper;
import com.orangelife.R;

/**
 * 测试: 具有分页功能的 Recyclerview 布局管理器
 * <p>
 * GcsSloop/pager-layoutmanager: [暂停维护]Android 网格分页布局。
 * https://github.com/GcsSloop/pager-layoutmanager
 * <p>
 * repositories {maven { url "http://lib.gcssloop.com/repository/gcssloop-central/" }}
 * <p>
 * implementation 'com.gcssloop.recyclerview:pagerlayoutmanager:2.3.8'
 * <p>
 * Created by ZeroVoid on 2018-8-10.
 */

public class TestPagerLayoutManagerAct extends AppCompatActivity {
    private RecyclerView rv;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_pager_layout_manager);
        initView();
    }

    private void initView() {
        rv = findViewById(R.id.rv);
        //int orientation=PagerGridLayoutManager.VERTICAL;//纵向分页
        int orientation = PagerGridLayoutManager.HORIZONTAL;//横向分页
        // 1.水平分页布局管理器
        PagerGridLayoutManager layoutManager = new PagerGridLayoutManager(
                2, 3, orientation);
        rv.setLayoutManager(layoutManager);

        // 2.设置滚动辅助工具
        PagerGridSnapHelper pageSnapHelper = new PagerGridSnapHelper();
        pageSnapHelper.attachToRecyclerView(rv);
        MyAdapter mAdapter = new MyAdapter();
        rv.setAdapter(mAdapter);
    }
}
